package com.hyx.api.controller.applet_shop;

import com.hyx.api.config.ApiPrefixRestController;
import com.hyx.api.domain.PriceDownFormula;
import com.hyx.api.domain.bo.PriceDownFormulaBo;
import com.hyx.api.service.IAppShopService;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 压价接口
 */
@RequiredArgsConstructor
@ApiPrefixRestController
@RequestMapping("/appShopApi/order")
public class ShopRateController {

    private final IAppShopService appShopService;

    /**
     * 修改压价设置状态
     * 1:开启压价
     * 0:关闭压价
     *
     * @param isOpen
     * @return
     */
    @GetMapping("/updateRateOpen")
    public AjaxResult updateRateOpen(@RequestParam Integer isOpen) {
        return appShopService.updateRateOpen(isOpen);
    }

    /**
     * 创建/更新门店压价公式表
     *
     * @param bo
     * @return
     */
    @PostMapping("/createOrUpdatePriceDown")
    public AjaxResult createOrUpdatePriceDown(@RequestBody PriceDownFormula bo) {
        return appShopService.createOrUpdatePriceDown(bo);
    }

    /**
     * 删除门店压价公式表
     *
     * @param id
     * @return
     */
    @GetMapping("/deletePriceDown")
    public AjaxResult deletePriceDown(@RequestParam Integer id) {
        return appShopService.deletePriceDown(id);
    }

    /**
     * 获取门店压价公式列表和公司压价开关
     *
     * @return
     */
    @GetMapping("/queryPriceDownList")
    public AjaxResult queryPriceDownList() {
        return appShopService.queryPriceDownList();
    }
}
